home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 1995
- //
- // Description:
- // This implements the group of controls that represents the
- // shelf. The shelf can either be part of a window
- // or in a window of its own.
- //
- // Input Arguments:
- // The name of the layout that the shelf should add itself
- // to. If empty, then this script will create a window.
- //
- // Return Value:
- // The name of the top level layout control.
- // (Used for embedding within another window)
- //
-
- global proc buildShelfMenu( string $parent )
- //
- // Create the popup menu that allows users to switch between
- // shelf tabs. This is created each time it is selected to
- // keep it in sync.
- //
- {
- global string $gShelfTopLevel;
- global string $gShelfCollection = "";
-
- setParent -m $parent;
- menu -e -dai $parent;
- $gShelfCollection = `radioMenuItemCollection`;
-
- // Shelf tab listing
- string $curShelf = `tabLayout -q -selectTab $gShelfTopLevel`;
- string $shelfArray[] = `shelfTabLayout -q -childArray $gShelfTopLevel`;
- int $numShelves = size($shelfArray);
-
- for ($i=0; $i<$numShelves; ++$i) {
- string $cmd =
- "shelfTabLayout -edit -selectTabIndex "+($i+1)+" "+$gShelfTopLevel+"; "
- +"optionVar -iv selectedShelf `tabLayout -q -sti "+$gShelfTopLevel+"`";
- int $enabled = ($shelfArray[$i] == $curShelf);
- menuItem -ecr false -radioButton $enabled -cl $gShelfCollection
- -l $shelfArray[$i] -c $cmd;
- }
- }
-
- global proc shelfTabChange()
- //
- // Description:
- // This procedure is called whenever the user selects a new
- // active shelf tab.
- //
- // Update the active shelf preference.
- //
- {
- global string $gShelfTopLevel;
-
- int $activeShelfTab;
-
- $activeShelfTab = `shelfTabLayout -query -selectTabIndex $gShelfTopLevel`;
-
- optionVar -intValue "selectedShelf" $activeShelfTab;
- }
-
- global proc toggleShelfTabs ()
- {
- global string $gShelfTopLevel;
-
- // Set optionVar to the opposite of the current state
- int $newState = !`optionVar -q shelfTabsVisible`;
- optionVar -intValue "shelfTabsVisible" $newState;
- shelfTabLayout -e -tv $newState $gShelfTopLevel;
-
- setShelfStyle `optionVar -query shelfItemStyle`
- `optionVar -query shelfItemSize`;
- }
-
- global proc buildShelves() {
-
- global string $gShelfTopLevel;
-
- setParent $gShelfTopLevel;
-
- // Define a template for shelf layouts.
- //
- if (!`uiTemplate -exists shelfLayoutTemplate`) {
- uiTemplate shelfLayoutTemplate;
- shelfLayout -dt shelfLayoutTemplate -h 34 -cwh 34 34;
- }
-
- // Activate the shelf layout template.
- //
- setUITemplate -pushTemplate shelfLayoutTemplate;
-
- string $varName, $cmd, $shelfFile, $shelfName;
- int $i, $nShelves;
-
- $nShelves = `optionVar -q numShelves`;
- int $isFile;
- for ($i = 1; $i <= $nShelves; $i++) {
- $varName = ("shelfName" + $i);
- $shelfName = `optionVar -q $varName`;
-
- $cmd = ("shelfLayout " + $shelfName);
- eval $cmd;
-
- $varName = ("shelfFile" + $i);
- $shelfFile = `optionVar -q $varName`;
- if ($shelfFile != 0) {
- $isFile = `exists $shelfFile`;
- if ($isFile != 0) {
-
- // If we use evalContinue then we aren't notified if there are any errors
- // evalContinue $shelfFile;
-
- if (catch(eval($shelfFile))) {
- string $returnStr;
- string $msg =
- "The shelf \""+$shelfName+"\" has items that cannot be read.\n"
- +"The shelf will only display the items before the first unreadable item it finds.\n"
- +"If you start Maya and save this shelf then you will lose the unreadable items.\n"
- +"This will happen automatically if you have your preferences set to save the shelves on exit.";
- $returnStr = `confirmDialog -title "Shelf Error"
- -message $msg
- -button "Continue"
- -button "Quit Maya"`;
- if ("Quit Maya" == $returnStr) {
- quit -f;
- }
- }
- }
- }
-
- setParent ..;
- }
-
- // Deactivate the shelf layout template.
- //
- setUITemplate -popTemplate;
-
- // Define the default active shelf if a preference does not
- // exist yet.
- //
- if (!`optionVar -exists "selectedShelf"`) {
- // Maya Personal Learning Edition should default to showing
- // the General Tab for brand-new users.
- //
- if (`about -windows` && (!`about -evalVersion`) ) {
- optionVar -intValue "selectedShelf" 4;
- } else {
- optionVar -intValue "selectedShelf" 1;
- }
- }
-
- // Get the selected tab preference and make that shelf tab active.
- //
- int $activeTab = `optionVar -query "selectedShelf"`;
-
- // Make sure the tab preference is valid given the number of
- // tabs in the shelf, ie. it should be a number ranging from
- // 1 to the number of tabs in the shelf.
- //
- if ($activeTab < 1
- || $activeTab > `tabLayout -query -numberOfChildren $gShelfTopLevel`) {
- //
- // The active tab preference is not valid given the number
- // of tabs in the Shelf.
- //
- // Reset the preference to the first shelf tab.
- //
- $activeTab = 1;
- optionVar -intValue "selectedShelf" $activeTab;
- }
-
- tabLayout -edit -selectTabIndex $activeTab $gShelfTopLevel;
-
- // Set the display style for the buttons on the Shelf.
- //
- setShelfStyle `optionVar -query shelfItemStyle`
- `optionVar -query shelfItemSize`;
- }
-
- {
- global string $gShelfForm;
- global string $gShelfTopLevel;
-
- int $bottomSpacing;
-
- // Create a layout appropriate for the Shelf.
- //
- string $shelfLayout = `formLayout -parent $gShelfForm`;
-
- //////////////////////////////////////////////////////////////////////
- //
- // Create the Menu and Options area.
- //
- //////////////////////////////////////////////////////////////////////
-
- setParent $shelfLayout;
-
- string $options = `frameLayout
- -parent $shelfLayout
- -borderVisible true
- -borderStyle "in"
- -labelVisible false
- -collapse false
- -collapsable false`;
-
- string $optionsLayout = `formLayout`;
-
- string $shelvesButton = `iconTextButton
- -image1 "shelfTab.xpm"
- -annotation "Change which shelf tab is displayed"
- -height 15 -width 20`;
-
- string $shelvesSeparator = `separator`;
-
- string $optionsButton = `iconTextStaticLabel
- -image1 "shelfOptions.xpm"
- -annotation "Menu of items to modify the shelf"
- -height 16 -width 20`;
-
- setParent ..;
-
- // For improving the alignment of shelves buttons.
- //
- if (`about -nt`) {
- $bottomSpacing = 0;
- } else {
- $bottomSpacing = 1;
- }
-
- formLayout -edit
- -attachNone $shelvesButton "top"
- -attachForm $shelvesButton "left" 0
- -attachControl $shelvesButton "bottom" $bottomSpacing $shelvesSeparator
- -attachForm $shelvesButton "right" 0
-
- -attachNone $shelvesSeparator "top"
- -attachForm $shelvesSeparator "left" 0
- -attachControl $shelvesSeparator "bottom" 0 $optionsButton
- -attachForm $shelvesSeparator "right" 0
-
- -attachNone $optionsButton "top"
- -attachForm $optionsButton "left" 0
- -attachForm $optionsButton "bottom" 0
- -attachForm $optionsButton "right" 0
- $optionsLayout;
-
- // Get the tab visible state.
- //
- if (!`optionVar -exists "shelfTabsVisible"`) {
- //
- // The shelf tabs are visible for Windows only.
- //
- int $visible = false;
- if (`about -windows`) {
- $visible = true;
- }
- optionVar -intValue "shelfTabsVisible" $visible;
- }
- int $tabVis = `optionVar -q shelfTabsVisible`;
-
- // Create the tab-switching menu
- //
- string $menu = `popupMenu -button 1 -parent $shelvesButton`;
- menu -edit -postMenuCommand ( "buildShelfMenu " + $menu ) $menu;
-
- // Create the options menu
- //
- $menu = `popupMenu -button 1 -parent $optionsButton`;
- menuItem -ecr false -cb $tabVis -c "toggleShelfTabs" -l "Shelf Tabs";
- menuItem -d true;
- menuItem -ecr false -l "Shelf Editor..." -c "shelfEditorDialog";
- menuItem -d true;
- menuItem -ecr false -l "New Shelf" -c "createNewShelf";
- string $cmd = "deleteShelfTab(`tabLayout -q -selectTab $gShelfTopLevel`);";
- menuItem -ecr false -l "Delete Shelf" -c $cmd;
- menuItem -d true;
- menuItem -ecr false -l "Load Shelf..." -c "loadNewShelf \"\"";
- menuItem -d true;
- menuItem -ecr false -l "Save All Shelves" -c "saveAllShelves $gShelfTopLevel";
-
- //////////////////////////////////////////////////////////////////////
- //
- // Create the Shelf.
- //
- //////////////////////////////////////////////////////////////////////
- $gShelfTopLevel = `shelfTabLayout
- -parent $shelfLayout
- -tabsVisible $tabVis
- -image "smallTrash.xpm"
- -imageVisible true
- -changeCommand ("shelfTabChange")
- ShelfLayout`;
-
- // For improving the alignment of options buttons.
- //
- if (`about -nt`) {
- $bottomSpacing = 1;
- } else {
- $bottomSpacing = 0;
- }
-
- // Layout Shelf.
- //
- formLayout -edit
- -attachNone $options "top"
- -attachForm $options "left" 2
- -attachForm $options "bottom" $bottomSpacing
- -attachNone $options "right"
-
- -attachForm $gShelfTopLevel "top" 0
- -attachControl $gShelfTopLevel "left" 0 $options
- -attachForm $gShelfTopLevel "bottom" 0
- -attachForm $gShelfTopLevel "right" 0
- $shelfLayout;
-
- // Attach Shelf to parent.
- //
- formLayout -edit
- -attachForm $shelfLayout "top" 0
- -attachForm $shelfLayout "left" 0
- -attachForm $shelfLayout "bottom" 0
- -attachForm $shelfLayout "right" 0
- $gShelfForm;
- }
-
-